package com.lyf.scm.plan.domain.service.impl;

import cn.hutool.core.date.DateUtil;
import com.lyf.scm.common.constants.BigDataEsConstants;
import com.lyf.scm.common.constants.CommonConstants;
import com.lyf.scm.common.enums.BigDataChannelEnum;
import com.lyf.scm.common.enums.OpContentEnum;
import com.lyf.scm.common.enums.OperationDataEnum;
import com.lyf.scm.common.enums.ResponseMsg;
import com.lyf.scm.plan.api.dto.StoreInfoDTO;
import com.lyf.scm.plan.domain.convertor.BigDataBaseConvertor;
import com.lyf.scm.plan.domain.remote.bigdata.dto.BigDataGeneralInfoDTO;
import com.lyf.scm.plan.domain.remote.bigdata.dto.BigDataGeneralQueryBaseDTO;
import com.lyf.scm.plan.domain.remote.bigdata.facade.CprfCoreFacade;
import com.lyf.scm.plan.domain.remote.item.dto.CategorySimpleDTO;
import com.lyf.scm.plan.domain.remote.item.dto.SkuInfoDTO;
import com.lyf.scm.plan.domain.remote.item.facade.ItemCoreFacade;
import com.lyf.scm.plan.domain.repository.OperationLogRecordRepository;
import com.lyf.scm.plan.domain.service.BigDataEsSolutionService;
import com.lyf.scm.plan.domain.util.BigDataCacheUtil;
import com.lyf.scm.plan.domain.util.OperationLogRecordUtil;
import com.lyf.scm.plan.insfrastructure.db.dataobject.OperationLogRecordDO;
import com.lyf.scm.plan.insfrastructure.db.dataobject.bigdata.*;
import com.lyf.scm.plan.insfrastructure.db.dataobject.es.SalesPlanEsEntity;
import com.rome.arch.util.IdWorker;
import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.index.query.QueryBuilders;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.query.IndexQuery;
import org.springframework.data.elasticsearch.core.query.IndexQueryBuilder;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.SearchQuery;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

import static com.lyf.scm.common.util.BatchHandlerUtil.splitTo;
import static com.lyf.scm.plan.domain.util.BigDataCacheUtil.*;
import static org.elasticsearch.index.query.QueryBuilders.*;

/**
 * es解决方案
 *
 * @author wangchlei
 * @date 2020/10/20
 */
@Slf4j
@Service
public class BigDataEsSolutionServiceImpl implements BigDataEsSolutionService {
    @Resource
    private ElasticsearchTemplate elasticsearchTemplate;
    @Resource
    private RedisCacheServiceImpl redisCacheServiceImpl;
    @Resource
    private OperationLogRecordRepository operationLogRecordRepository;
    @Resource
    private ItemCoreFacade itemCoreFacade;
    @Resource
    private BigDataBaseConvertor bigDataBaseConvertor;
    /**
     * 远程调用
     */
    @Resource
    private CprfCoreFacade cprfCoreFacade;
    /**
     * 是否触发周任务
     */
    private boolean validWeekJob;
    /**
     * 标识
     */
    private String opSign;

    /**
     * 拉取大数据数据（调用日补货接口，直营门店）
     *
     * @param
     * @return void
     **/
    @Async
    @Override
    public void handleApiDispatcher() {
        long startTime = System.currentTimeMillis();
        Map<String, StoreInfoDTO> storesInfo = redisCacheServiceImpl.getDirectStores();
        log.info("\n【大数据Job】：已获取所有直营门店,门店数量 {}", storesInfo.size());
        //初始化必要数据的缓存
        this.initCacheData();
        log.info("\n【大数据Job】：开始处理所有直营门店");
        storesInfo.keySet().forEach(item -> this.handleStore(storesInfo.get(item)));
        long endTime = System.currentTimeMillis();
        this.writeOperateLog(endTime - startTime);
    }

    @Override
    public void createIndex() {
        //创建索引
        elasticsearchTemplate.createIndex(SalesPlanEsEntity.class);
        elasticsearchTemplate.putMapping(SalesPlanEsEntity.class);
//        elasticsearchTemplate.createIndex(SalesPlanDifferinEntity.class);
//        elasticsearchTemplate.createIndex(SalesPlanAccuracyEntity.class);
//        elasticsearchTemplate.putMapping(SalesPlanExecuteEntity.class);
//        elasticsearchTemplate.putMapping(SalesPlanDirectlyEntity.class);
//        elasticsearchTemplate.putMapping(SalesPlanDifferinEntity.class);
//        elasticsearchTemplate.putMapping(SalesPlanAccuracyEntity.class);
    }

    /**
     * 处理每一个门店
     *
     * @param storeInfo
     * @return void
     **/
    private void handleStore(StoreInfoDTO storeInfo) {
        long globalStartTime = System.currentTimeMillis();
        List<IndexQuery> queryList;
        //大数据信息
        long handleStartTime = System.currentTimeMillis();
        List<BigDataGeneralInfoDTO> bigDataGeneralInfoDTOs = null;
        try {
            //获取查询条件
            BigDataGeneralQueryBaseDTO bigDataGeneralQueryBaseDTO = this.getGeneralQueryBaseDTO(storeInfo.getCode(), BigDataCacheUtil.nowDate);
            //根据时间段，门店等信息  递归分页获取所有大数据信息
            bigDataGeneralInfoDTOs = this.getBigDataGeneralInfo(bigDataGeneralQueryBaseDTO);
            //合理默认两个表的状态是统一的，且其数据量数据结构是一致的（数据数量，sku,门店等是统一的）
            if (!CollectionUtils.isEmpty(bigDataGeneralInfoDTOs)) {
                if (validWeekJob) {
                    queryList = this.getDayAndWeekResult(storeInfo, bigDataGeneralInfoDTOs);
                } else {
                    queryList = this.getDayResult(storeInfo, bigDataGeneralInfoDTOs);
                }
            } else {
                log.warn("\n【大数据Job】：门店数据无数据：code {}  name {}", storeInfo.getCode(), storeInfo.getName());
                return;
            }
        } catch (feign.RetryableException retryableException) {
            long handleEndTime = System.currentTimeMillis();
            retryableException.printStackTrace();
            log.error("\n【大数据Job】：门店数据处理失败：code {}  name {}", storeInfo.getCode(), storeInfo.getName() + " 失败原因：" + retryableException.getMessage());
            this.writeErrorLog(storeInfo.getCode(), retryableException.getMessage(), (handleEndTime - handleStartTime), bigDataGeneralInfoDTOs.size());
            return;
        } catch (Exception e) {
            long handleEndTime = System.currentTimeMillis();
            e.printStackTrace();
            log.error("\n【大数据Job】：门店数据处理失败：code {}  name {}", storeInfo.getCode(), storeInfo.getName() + " 失败原因：" + ResponseMsg.FAIL_5004.getMsg());
            this.writeErrorLog(storeInfo.getCode(), ResponseMsg.FAIL_5004.getMsg(), (handleEndTime - handleStartTime), bigDataGeneralInfoDTOs.size());
            return;
        }
        long sqlStartTime = System.currentTimeMillis();
        try {
            this.handleBigData(queryList);
        } catch (Exception e) {
            long sqlEndTime = System.currentTimeMillis();
            e.printStackTrace();
            log.error("\n【大数据Job】：门店数据处理失败：code {}  name {}", storeInfo.getCode(), storeInfo.getName() + " 失败原因：" + ResponseMsg.FAIL_5005.getMsg());
            this.writeErrorLog(storeInfo.getCode(), ResponseMsg.FAIL_5005.getMsg(), (sqlEndTime - sqlStartTime), queryList.size());
            return;
        }
        long globalEndTime = System.currentTimeMillis();
        log.info("\n【大数据Job】：门店数据处理成功：code {}  name {}  耗时 {}", storeInfo.getCode(), storeInfo.getName(), (globalEndTime - globalStartTime) + "ms");
    }

    /**
     * 初始化必要的缓存信息
     *
     * @param
     * @return void
     **/
    private void initCacheData() {
        Date date = new Date();
        //判断是否需要触发周任务
        this.validWeekJob = validWeekJob(date);
        //注入周和日的处理缓存信息
        BigDataCacheUtil.injectDayCache(date);
        BigDataCacheUtil.injectWeekCache(date);
        //数据标识
        IdWorker idWorker = new IdWorker();
        opSign = "" + idWorker.getId();
    }

    /**
     * 将结果写入es
     *
     * @param queryList
     * @return void
     **/
    private void handleBigData(List<IndexQuery> queryList) {
        long startTime = System.currentTimeMillis();
        if (!CollectionUtils.isEmpty(queryList)) {
            List<List<IndexQuery>> lists = splitTo(queryList, 50000);
            for (List<IndexQuery> list : lists) {
                elasticsearchTemplate.bulkIndex(list);
            }
        }
        long endTime = System.currentTimeMillis();
        log.info("\n【大数据Job】：写入耗时 {}", (endTime - startTime) + "ms");
    }

    /**
     * 写错误日志到mysql
     *
     * @param storeCode
     * @param msg
     * @param time
     * @param size
     * @return void
     **/
    private void writeErrorLog(String storeCode, String msg, long time, int size) {
        List<OperationLogRecordDO> operationLogRecordDOs = new ArrayList<>(4);
        operationLogRecordDOs.add(OperationLogRecordUtil.getBigDataErrorLog(storeCode, OperationDataEnum.DIRECTLY_EXECUTE.getTableType(), msg, size, time + "ms", OpContentEnum.BIG_DATA_ERROR_DIRECT_LOG.getIndex().toString(), OpContentEnum.BIG_DATA_ERROR_DIRECT_LOG.getDesc()));
        if (validWeekJob) {
            operationLogRecordDOs.add(OperationLogRecordUtil.getBigDataErrorLog(storeCode, OperationDataEnum.DIRECTLY_ACCURACY.getTableType(), msg, size, time + "ms", OpContentEnum.BIG_DATA_ERROR_DIRECT_LOG.getIndex().toString(), OpContentEnum.BIG_DATA_ERROR_DIRECT_LOG.getDesc()));
            operationLogRecordDOs.add(OperationLogRecordUtil.getBigDataErrorLog(storeCode, OperationDataEnum.DIRECTLY_DIFFERIN.getTableType(), msg, size, time + "ms", OpContentEnum.BIG_DATA_ERROR_DIRECT_LOG.getIndex().toString(), OpContentEnum.BIG_DATA_ERROR_DIRECT_LOG.getDesc()));
            operationLogRecordDOs.add(OperationLogRecordUtil.getBigDataErrorLog(storeCode, OperationDataEnum.PLAN_DIRECTLY.getTableType(), msg, size, time + "ms", OpContentEnum.BIG_DATA_ERROR_DIRECT_LOG.getIndex().toString(), OpContentEnum.BIG_DATA_ERROR_DIRECT_LOG.getDesc()));
        }
        operationLogRecordRepository.batchAddBigDataErrorLog(operationLogRecordDOs);
    }

    /**
     * 获取天维度的计算结果
     *
     * @param storeInfo
     * @param bigDataGeneralInfoDTOs
     * @return {@link List<IndexQuery>}
     **/
    private List<IndexQuery> getDayResult(StoreInfoDTO storeInfo, List<BigDataGeneralInfoDTO> bigDataGeneralInfoDTOs) {
        List<SalesPlanExecuteEntity> upSalesPlanExecuteEntitys = this.getHistoryOfExecute(storeInfo.getCode());
        if (CollectionUtils.isEmpty(upSalesPlanExecuteEntitys)) {
            upSalesPlanExecuteEntitys = new ArrayList<>(1);
        }
        return this.initalUpDayData(upSalesPlanExecuteEntitys, storeInfo, bigDataGeneralInfoDTOs);
    }

    /**
     * 获取天和周维度计算结果
     *
     * @param storeInfo
     * @param bigDataGeneralInfoDTOs
     * @return {@link List<IndexQuery>}
     **/
    private List<IndexQuery> getDayAndWeekResult(StoreInfoDTO storeInfo, List<BigDataGeneralInfoDTO> bigDataGeneralInfoDTOs) {
        //直营预测——执行 根据门店和日期获取所有需要更新的数据（默认为13天数据，今日起）
        List<SalesPlanExecuteEntity> upSalesPlanExecuteEntitys = this.getHistoryOfExecute(storeInfo.getCode());
        List<SalesPlanDirectlyEntity> upSalesPlanDirectlyEntitys = this.getHistoryOfDirectly(storeInfo.getCode());
        List<SalesPlanDifferinEntity> upSalesPlanDifferinEntitys = this.getHistoryOfDifferin(storeInfo.getCode());
        List<SalesPlanAccuracyEntity> upSalesPlanAccuracyEntitys = this.getHistoryOfAccuracy(storeInfo.getCode());
        if (CollectionUtils.isEmpty(upSalesPlanExecuteEntitys)) {
            upSalesPlanExecuteEntitys = new ArrayList<>(1);
        }
        if (CollectionUtils.isEmpty(upSalesPlanDirectlyEntitys)) {
            upSalesPlanDirectlyEntitys = new ArrayList<>(1);
        }
        if (CollectionUtils.isEmpty(upSalesPlanDifferinEntitys)) {
            upSalesPlanDifferinEntitys = new ArrayList<>(1);
        }
        if (CollectionUtils.isEmpty(upSalesPlanAccuracyEntitys)) {
            upSalesPlanAccuracyEntitys = new ArrayList<>(1);
        }
        return this.initalUpDayUpWeekData(upSalesPlanExecuteEntitys, upSalesPlanDirectlyEntitys, upSalesPlanDifferinEntitys, upSalesPlanAccuracyEntitys, storeInfo, bigDataGeneralInfoDTOs);
    }

    /**
     * 获取天维度结果细节
     *
     * @param upSalesPlanExecuteEntitys
     * @param storeInfo
     * @param bigDataGeneralInfoDTOs
     * @return {@link List<IndexQuery>}
     **/
    private List<IndexQuery> initalUpDayData(List<SalesPlanExecuteEntity> upSalesPlanExecuteEntitys, StoreInfoDTO storeInfo, List<BigDataGeneralInfoDTO> bigDataGeneralInfoDTOs) {
        //查询sku信息
        List<SkuInfoDTO> skuInfoDTOS = itemCoreFacade.skuListBySkuCodes(bigDataGeneralInfoDTOs.stream().map(BigDataGeneralInfoDTO::getSkuKey).distinct().collect(Collectors.toList()));
        Map<String, SkuInfoDTO> skuCodeName = this.getSkuInfo(skuInfoDTOS);
        Map<Integer, List<CategorySimpleDTO>> categoryInfo = this.getCategoryInfo(skuInfoDTOS);
        //遍历
        int countStore;
        String skuKey;
        BaseEntity baseEntity;
        List<IndexQuery> queryList = new ArrayList<>();
        for (BigDataGeneralInfoDTO bigDataGeneralInfoDTO : bigDataGeneralInfoDTOs) {
            skuKey = bigDataGeneralInfoDTO.getSkuKey();
            //直营预测————门店
            countStore = 0;
            for (SalesPlanExecuteEntity salesPlanExecuteEntity : upSalesPlanExecuteEntitys) {
                //如果是同一条sku,默认取十三天为更新数据，第十四条为新增数据 存入集合中
                if (skuKey.equals(salesPlanExecuteEntity.getSkuCode())) {
                    //更新其同用属性（区域，品类）
                    this.setGeneralInfo(salesPlanExecuteEntity, skuKey, storeInfo, skuCodeName, categoryInfo);
                    //设置更新及重置属性值
                    this.setExecutePredictValue(salesPlanExecuteEntity, bigDataGeneralInfoDTO);
                    //设置es更新对象
                    queryList.add(new IndexQueryBuilder().withObject(salesPlanExecuteEntity).withId(salesPlanExecuteEntity.getId()).build());
                    countStore++;
                }
            }
            //如果含有更新数据————加入门店第十四天新增数据   执行所有新增数据,否则新增所有天数据
            baseEntity = this.createGeneralDayInDO(skuKey, storeInfo, skuCodeName, categoryInfo);
            if (countStore != 0) {
                queryList.add(this.getNewExecuteStore(baseEntity, bigDataGeneralInfoDTO.getSalesDayf14()));
            } else {
                //遍历十四天信息
                this.getDayDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesDayf1(), dayStr1);
                this.getDayDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesDayf2(), dayStr2);
                this.getDayDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesDayf3(), dayStr3);
                this.getDayDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesDayf4(), dayStr4);
                this.getDayDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesDayf5(), dayStr5);
                this.getDayDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesDayf6(), dayStr6);
                this.getDayDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesDayf7(), dayStr7);
                this.getDayDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesDayf8(), dayStr8);
                this.getDayDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesDayf9(), dayStr9);
                this.getDayDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesDayf10(), dayStr10);
                this.getDayDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesDayf11(), dayStr11);
                this.getDayDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesDayf12(), dayStr12);
                this.getDayDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesDayf13(), dayStr13);
                this.getDayDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesDayf14(), dayStr14);
            }
        }
        return queryList;
    }

    /**
     * 获取天和周维度结果细节
     *
     * @param upSalesPlanExecuteEntitys
     * @param upSalesPlanDirectlyEntitys
     * @param upSalesPlanDifferinEntitys
     * @param upSalesPlanAccuracyEntitys
     * @param storeInfo
     * @param bigDataGeneralInfoDTOs
     * @return {@link List<IndexQuery>}
     **/
    private List<IndexQuery> initalUpDayUpWeekData(List<SalesPlanExecuteEntity> upSalesPlanExecuteEntitys, List<SalesPlanDirectlyEntity> upSalesPlanDirectlyEntitys, List<SalesPlanDifferinEntity> upSalesPlanDifferinEntitys, List<SalesPlanAccuracyEntity> upSalesPlanAccuracyEntitys, StoreInfoDTO storeInfo, List<BigDataGeneralInfoDTO> bigDataGeneralInfoDTOs) {
        //查询sku信息
        List<SkuInfoDTO> skuInfoDTOS = itemCoreFacade.skuListBySkuCodes(bigDataGeneralInfoDTOs.stream().map(BigDataGeneralInfoDTO::getSkuKey).distinct().collect(Collectors.toList()));
        Map<String, SkuInfoDTO> skuCodeName = this.getSkuInfo(skuInfoDTOS);
        Map<Integer, List<CategorySimpleDTO>> categoryInfo = this.getCategoryInfo(skuInfoDTOS);
        //遍历
        int countStore;
        int countDirect;
        String skuKey;
        BaseEntity baseEntity;
        List<IndexQuery> queryList = new ArrayList<>();
        for (BigDataGeneralInfoDTO bigDataGeneralInfoDTO : bigDataGeneralInfoDTOs) {
            skuKey = bigDataGeneralInfoDTO.getSkuKey();
            //直营预测————门店
            countStore = 0;
            countDirect = 0;
            for (SalesPlanExecuteEntity salesPlanExecuteEntity : upSalesPlanExecuteEntitys) {
                //如果是同一条sku,默认取十三天为更新数据，第十四条为新增数据 存入集合中
                if (skuKey.equals(salesPlanExecuteEntity.getSkuCode())) {
                    //更新其同用属性（区域，品类）
                    this.setGeneralInfo(salesPlanExecuteEntity, skuKey, storeInfo, skuCodeName, categoryInfo);
                    //设置更新及重置属性值
                    this.setExecutePredictValue(salesPlanExecuteEntity, bigDataGeneralInfoDTO);
                    //设置es更新对象
                    queryList.add(new IndexQueryBuilder().withObject(salesPlanExecuteEntity).withId(salesPlanExecuteEntity.getId()).build());
                    countStore++;
                }
            }
            //如果含有更新数据————加入门店第十四天新增数据   执行所有新增数据,否则新增所有天数据
            baseEntity = this.createGeneralDayInDO(skuKey, storeInfo, skuCodeName, categoryInfo);
            if (countStore != 0) {
                queryList.add(this.getNewExecuteStore(baseEntity, bigDataGeneralInfoDTO.getSalesDayf14()));
            } else {
                //遍历十四天信息
                this.getDayDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesDayf1(), dayStr1);
                this.getDayDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesDayf2(), dayStr2);
                this.getDayDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesDayf3(), dayStr3);
                this.getDayDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesDayf4(), dayStr4);
                this.getDayDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesDayf5(), dayStr5);
                this.getDayDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesDayf6(), dayStr6);
                this.getDayDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesDayf7(), dayStr7);
                this.getDayDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesDayf8(), dayStr8);
                this.getDayDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesDayf9(), dayStr9);
                this.getDayDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesDayf10(), dayStr10);
                this.getDayDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesDayf11(), dayStr11);
                this.getDayDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesDayf12(), dayStr12);
                this.getDayDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesDayf13(), dayStr13);
                this.getDayDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesDayf14(), dayStr14);
            }
            //遍历十三周数据
            for (SalesPlanDirectlyEntity item : upSalesPlanDirectlyEntitys) {
                if (skuKey.equals(item.getSkuCode())) {
                    this.setGeneralInfo(item, skuKey, storeInfo, skuCodeName, categoryInfo);
                    this.setDirectlyPredictValue(item, bigDataGeneralInfoDTO);
                    //设置es更新对象
                    queryList.add(new IndexQueryBuilder().withObject(item).withId(item.getId()).build());
                    countDirect++;
                }
            }
            if (countDirect != 0) {
                queryList.add(this.getNewDirectly(baseEntity, bigDataGeneralInfoDTO.getSalesWeekf13()));
                for (SalesPlanDifferinEntity item : upSalesPlanDifferinEntitys) {
                    //如果是同一条sku,默认取十三天为更新数据，第十四条为新增数据 存入集合中
                    if (skuKey.equals(item.getSkuCode())) {
                        //更新其同用属性（区域，品类）
                        this.setGeneralInfo(item, skuKey, storeInfo, skuCodeName, categoryInfo);
                        //设置更新及重置属性值
                        this.setDifferinPredictValue(item, bigDataGeneralInfoDTO);
                        //设置es更新对象
                        queryList.add(new IndexQueryBuilder().withObject(item).withId(item.getId()).build());
                    }
                }
                queryList.add(this.getNewDifferin(baseEntity, bigDataGeneralInfoDTO.getSalesWeekf13()));
                for (SalesPlanAccuracyEntity item : upSalesPlanAccuracyEntitys) {
                    //如果是同一条sku,默认取十三天为更新数据，第十四条为新增数据 存入集合中
                    if (skuKey.equals(item.getSkuCode())) {
                        //更新其同用属性（区域，品类）
                        this.setGeneralInfo(item, skuKey, storeInfo, skuCodeName, categoryInfo);
                        //设置更新及重置属性值
                        this.setAccuracyPredictValue(item, bigDataGeneralInfoDTO);
                        //设置es更新对象
                        queryList.add(new IndexQueryBuilder().withObject(item).withId(item.getId()).build());
                    }
                }
                queryList.add(this.getNewAccuracy(baseEntity, bigDataGeneralInfoDTO.getSalesWeekf13()));
            } else {
                this.getWeekDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesWeekf1(), startDateStr1, endDateStr1);
                this.getWeekDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesWeekf2(), startDateStr2, endDateStr2);
                this.getWeekDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesWeekf3(), startDateStr3, endDateStr3);
                this.getWeekDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesWeekf4(), startDateStr4, endDateStr4);
                this.getWeekDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesWeekf5(), startDateStr5, endDateStr5);
                this.getWeekDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesWeekf6(), startDateStr6, endDateStr6);
                this.getWeekDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesWeekf7(), startDateStr7, endDateStr7);
                this.getWeekDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesWeekf8(), startDateStr8, endDateStr8);
                this.getWeekDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesWeekf9(), startDateStr9, endDateStr9);
                this.getWeekDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesWeekf10(), startDateStr10, endDateStr10);
                this.getWeekDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesWeekf11(), startDateStr11, endDateStr11);
                this.getWeekDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesWeekf12(), startDateStr12, endDateStr12);
                this.getWeekDO(baseEntity, queryList, bigDataGeneralInfoDTO.getSalesWeekf13(), startDateStr13, endDateStr13);
            }
        }
        return queryList;
    }

    private void getDayDO(BaseEntity baseEntity, List<IndexQuery> queryList, BigDecimal sales, String date) {
        SalesPlanExecuteEntity salesPlanExecuteEntity = bigDataBaseConvertor.baseEnToExecuteEn(baseEntity);
        //设置日期
        salesPlanExecuteEntity.setFormulateDate(date);
        //设置预测量
        salesPlanExecuteEntity.setForecastSalesAmount(sales);
        queryList.add(new IndexQueryBuilder().withObject(salesPlanExecuteEntity).build());
    }

    /**
     * 获取所有周维度的某一周结果
     *
     * @param baseEntity
     * @param queryList
     * @param sales
     * @param startDate
     * @param endDate
     * @return void
     **/
    private void getWeekDO(BaseEntity baseEntity, List<IndexQuery> queryList, BigDecimal sales, String startDate, String endDate) {
        SalesPlanAccuracyEntity salesPlanAccuracyEntity = bigDataBaseConvertor.baseEnToAccuracyEn(baseEntity);
        SalesPlanDifferinEntity salesPlanDifferinEntity = bigDataBaseConvertor.baseEnToDifferinEn(baseEntity);
        SalesPlanDirectlyEntity salesPlanDirectlyEntity = bigDataBaseConvertor.baseEnToDirectlyEn(baseEntity);
        //设置日期
        salesPlanAccuracyEntity.setPlanStartDate(startDate);
        salesPlanAccuracyEntity.setPlanEndDate(endDate);
        salesPlanDifferinEntity.setPlanStartDate(startDate);
        salesPlanDifferinEntity.setPlanEndDate(endDate);
        salesPlanDirectlyEntity.setPlanStartDate(startDate);
        salesPlanDirectlyEntity.setPlanEndDate(endDate);
        //设置预测量
        salesPlanAccuracyEntity.setPredictedQty(sales);
        salesPlanDifferinEntity.setSalesForecastQty(sales);
        salesPlanDirectlyEntity.setForecastQty(sales);
        //加默认值
        salesPlanDirectlyEntity.setLastForecastQty(BigDecimal.ZERO);
        salesPlanDirectlyEntity.setConfirmTarget(BigDecimal.ZERO);
        queryList.add(new IndexQueryBuilder().withObject(salesPlanAccuracyEntity).build());
        queryList.add(new IndexQueryBuilder().withObject(salesPlanDifferinEntity).build());
        queryList.add(new IndexQueryBuilder().withObject(salesPlanDirectlyEntity).build());
    }

    private IndexQuery getNewExecuteStore(BaseEntity baseEntity, BigDecimal sales) {
        SalesPlanExecuteEntity salesPlanExecuteEntity = bigDataBaseConvertor.baseEnToExecuteEn(baseEntity);
        salesPlanExecuteEntity.setForecastSalesAmount(sales);
        salesPlanExecuteEntity.setFormulateDate(dayStr14);
        return new IndexQueryBuilder().withObject(salesPlanExecuteEntity).build();
    }

    private IndexQuery getNewDirectly(BaseEntity baseEntity, BigDecimal sales) {
        SalesPlanDirectlyEntity salesPlanDirectlyEntity = bigDataBaseConvertor.baseEnToDirectlyEn(baseEntity);
        salesPlanDirectlyEntity.setForecastQty(sales);
        salesPlanDirectlyEntity.setLastForecastQty(BigDecimal.ZERO);
        salesPlanDirectlyEntity.setPlanStartDate(startDateStr13);
        salesPlanDirectlyEntity.setPlanEndDate(endDateStr13);
        salesPlanDirectlyEntity.setConfirmTarget(BigDecimal.ZERO);
        return new IndexQueryBuilder().withObject(salesPlanDirectlyEntity).build();
    }

    private IndexQuery getNewDifferin(BaseEntity baseEntity, BigDecimal sales) {
        SalesPlanDifferinEntity salesPlanDifferinEntity = bigDataBaseConvertor.baseEnToDifferinEn(baseEntity);
        salesPlanDifferinEntity.setSalesForecastQty(sales);
        salesPlanDifferinEntity.setPlanStartDate(startDateStr13);
        salesPlanDifferinEntity.setPlanEndDate(endDateStr13);
        return new IndexQueryBuilder().withObject(salesPlanDifferinEntity).build();
    }

    private IndexQuery getNewAccuracy(BaseEntity baseEntity, BigDecimal sales) {
        SalesPlanAccuracyEntity salesPlanAccuracyEntity = bigDataBaseConvertor.baseEnToAccuracyEn(baseEntity);
        salesPlanAccuracyEntity.setPredictedQty(sales);
        salesPlanAccuracyEntity.setPlanStartDate(startDateStr13);
        salesPlanAccuracyEntity.setPlanEndDate(endDateStr13);
        return new IndexQueryBuilder().withObject(salesPlanAccuracyEntity).build();
    }

    private void setDirectExecuteValue(SalesPlanExecuteEntity salesPlanExecuteEntity, BigDecimal sales) {
        salesPlanExecuteEntity.setForecastSalesAmount(sales);
    }

    private void setDirectValue(SalesPlanDirectlyEntity salesPlanDirectlyEntity, BigDecimal sales) {
        salesPlanDirectlyEntity.setLastForecastQty(salesPlanDirectlyEntity.getForecastQty());
        salesPlanDirectlyEntity.setForecastQty(sales);
        salesPlanDirectlyEntity.setConfirmTarget(BigDecimal.ZERO);
    }

    private void setDifferinValue(SalesPlanDifferinEntity salesPlanDifferinEntity, BigDecimal sales) {
        salesPlanDifferinEntity.setSalesForecastQty(sales);
    }

    private void setAccuracyValue(SalesPlanAccuracyEntity salesPlanAccuracyEntity, BigDecimal sales) {
        salesPlanAccuracyEntity.setPredictedQty(sales);
    }

    private BaseEntity createGeneralDayInDO(String skuKey, StoreInfoDTO storeInfo, Map<String, SkuInfoDTO> skuCodeName, Map<Integer, List<CategorySimpleDTO>> categoryInfo) {
        BaseEntity baseEntity = new BaseEntity();
        baseEntity.setOpSign(opSign);
        //设置渠道信息
        baseEntity.setChannelCode(BigDataChannelEnum.STORE_DIRECT.getChannelCode());
        baseEntity.setChannelName(BigDataChannelEnum.STORE_DIRECT.getChannelName());
        //设置省市区 门店
        this.setGeneralAreaValue(baseEntity, storeInfo);
        baseEntity.setStoreCode(storeInfo.getCode());
        //设置大中小品类
        baseEntity.setSkuCode(skuKey);
        if (skuCodeName.get(skuKey) != null) {
            SkuInfoDTO skuInfoDTO = skuCodeName.get(skuKey);
            List<CategorySimpleDTO> categorySimpleDTOS = categoryInfo.get(skuInfoDTO.getCategoryId());
            if (!CollectionUtils.isEmpty(categorySimpleDTOS)) {
                BaseEntity finalBaseEntity = baseEntity;
                categorySimpleDTOS.forEach(subItem -> this.setGeneralCategoryValue(subItem, finalBaseEntity));
            }
        }
        return baseEntity;
    }


    private void setGeneralInfo(BaseEntity baseEntity, String skuKey, StoreInfoDTO storeInfo, Map<String, SkuInfoDTO> skuCodeName, Map<Integer, List<CategorySimpleDTO>> categoryInfo) {
        baseEntity.setOpSign(opSign);
        //设置渠道信息
        baseEntity.setChannelCode(BigDataChannelEnum.STORE_DIRECT.getChannelCode());
        baseEntity.setChannelName(BigDataChannelEnum.STORE_DIRECT.getChannelName());
        //设置省市区 门店
        this.setGeneralAreaValue(baseEntity, storeInfo);
        //设置大中小品类
        if (skuCodeName.get(skuKey) != null) {
            SkuInfoDTO skuInfoDTO = skuCodeName.get(skuKey);
            List<CategorySimpleDTO> categorySimpleDTOS = categoryInfo.get(skuInfoDTO.getCategoryId());
            if (!CollectionUtils.isEmpty(categorySimpleDTOS)) {
                BaseEntity finalBaseEntity = baseEntity;
                categorySimpleDTOS.forEach(subItem -> this.setGeneralCategoryValue(subItem, finalBaseEntity));
            }
        }
    }

    /**
     * 设置通用属性 设置品类
     *
     * @param subItem
     * @return void
     **/
    private void setGeneralCategoryValue(CategorySimpleDTO subItem, BaseEntity baseEntity) {
        Integer level = subItem.getCategoryLevel();
        switch (level) {
            case 2:
                baseEntity.setPriCategoryCode(String.valueOf(subItem.getCategoryCode()));
                break;
            case 3:
                baseEntity.setSecCategoryCode(String.valueOf(subItem.getCategoryCode()));
                break;
            case 4:
                baseEntity.setTerCategoryCode(String.valueOf(subItem.getCategoryCode()));
                break;
            default:
        }
    }

    /**
     * 设置通用属性 设置省市区 门店
     *
     * @param storeInfo
     * @return void
     **/
    private void setGeneralAreaValue(BaseEntity baseEntity, StoreInfoDTO storeInfo) {
        baseEntity.setProvinceCode(storeInfo.getProvinceCode());
        baseEntity.setCityCode(storeInfo.getCityCode());
        baseEntity.setCountyCode(storeInfo.getAreaCode());
    }

    /**
     * 根据skuInfo获取sku-map信息
     *
     * @param skuInfoDTOS
     * @return void
     **/
    private Map<String, SkuInfoDTO> getSkuInfo(List<SkuInfoDTO> skuInfoDTOS) {
        //根据skuCodes查询skuInfo
        Map<String, SkuInfoDTO> skuCodeName = new HashMap<>();
        if (!CollectionUtils.isEmpty(skuInfoDTOS)) {
            skuCodeName = skuInfoDTOS.stream().collect(Collectors.toMap(SkuInfoDTO::getSkuCode, item -> item));
        }
        return skuCodeName;
    }

    /**
     * 根据skuInfo获取sku品类信息
     *
     * @param skuInfoDTOS
     * @return void
     **/
    private Map<Integer, List<CategorySimpleDTO>> getCategoryInfo(List<SkuInfoDTO> skuInfoDTOS) {
        Map<Integer, List<CategorySimpleDTO>> categoryInfo = new HashMap<>();
        if (!CollectionUtils.isEmpty(skuInfoDTOS)) {
            List<CategorySimpleDTO> categorySimpleDTOS = itemCoreFacade.getAllCategoryByCategoryId(skuInfoDTOS.stream().map(SkuInfoDTO::getCategoryId).distinct().collect(Collectors.toList()));
            categoryInfo = categorySimpleDTOS.stream().collect(Collectors.toMap(CategorySimpleDTO::getId, CategorySimpleDTO::getParentCategoryDTOList));
        }
        return categoryInfo;
    }

    private List<SalesPlanExecuteEntity> getHistoryOfExecute(String storeCode) {
        // 获取所有周查询条件条件查询
        List<SearchQuery> groupQuerys = this.getDaySearchQuerys(BigDataEsConstants.INDEX_NAME_PLAN_EXECUTE, storeCode);
        //根据所有查询条件获取数据
        return this.getEsQueryResult(groupQuerys, SalesPlanExecuteEntity.class);
    }

    /**
     * 获取直营预测十二周历史数据
     *
     * @param storeCode
     * @return {@link List<SalesPlanDirectlyEntity>}
     **/
    private List<SalesPlanDirectlyEntity> getHistoryOfDirectly(String storeCode) {
        // 获取所有周查询条件条件查询
        List<SearchQuery> groupQuerys = this.getWeekSearchQuerys(BigDataEsConstants.INDEX_NAME_PLAN_DIRECTLY, storeCode);
        //根据所有查询条件获取数据
        return this.getEsQueryResult(groupQuerys, SalesPlanDirectlyEntity.class);
    }

    private List<SalesPlanDifferinEntity> getHistoryOfDifferin(String storeCode) {
        // 获取所有周查询条件条件查询
        List<SearchQuery> groupQuerys = this.getWeekSearchQuerys(BigDataEsConstants.INDEX_NAME_PLAN_DIFFERIN, storeCode);
        //根据所有查询条件获取数据
        return this.getEsQueryResult(groupQuerys, SalesPlanDifferinEntity.class);
    }

    private List<SalesPlanAccuracyEntity> getHistoryOfAccuracy(String storeCode) {
        // 获取所有周查询条件条件查询
        List<SearchQuery> groupQuerys = this.getWeekSearchQuerys(BigDataEsConstants.INDEX_NAME_PLAN_ACCURACY, storeCode);
        //根据所有查询条件获取数据
        List<SalesPlanAccuracyEntity> salesPlanAccuracyEntitys = this.getEsQueryResult(groupQuerys, SalesPlanAccuracyEntity.class);
        return salesPlanAccuracyEntitys;
    }

    private <T> List<T> getEsQueryResult(List<SearchQuery> groupQuerys, Class<T> entityClass) {
        List<T> entitys = new ArrayList<>();
        for (SearchQuery groupQuery : groupQuerys) {
            entitys.addAll(elasticsearchTemplate.queryForList(groupQuery, entityClass));
        }
        return entitys;
    }

    private List<SearchQuery> getWeekSearchQuerys(String indexName, String storeCode) {
        List<SearchQuery> searchQuerys = new ArrayList<>();
        searchQuerys.add(this.getWeekSearchQuery(indexName, storeCode, startDateStr1));
        searchQuerys.add(this.getWeekSearchQuery(indexName, storeCode, startDateStr2));
        searchQuerys.add(this.getWeekSearchQuery(indexName, storeCode, startDateStr3));
        searchQuerys.add(this.getWeekSearchQuery(indexName, storeCode, startDateStr4));
        searchQuerys.add(this.getWeekSearchQuery(indexName, storeCode, startDateStr5));
        searchQuerys.add(this.getWeekSearchQuery(indexName, storeCode, startDateStr6));
        searchQuerys.add(this.getWeekSearchQuery(indexName, storeCode, startDateStr7));
        searchQuerys.add(this.getWeekSearchQuery(indexName, storeCode, startDateStr8));
        searchQuerys.add(this.getWeekSearchQuery(indexName, storeCode, startDateStr9));
        searchQuerys.add(this.getWeekSearchQuery(indexName, storeCode, startDateStr10));
        searchQuerys.add(this.getWeekSearchQuery(indexName, storeCode, startDateStr11));
        searchQuerys.add(this.getWeekSearchQuery(indexName, storeCode, startDateStr12));
        return searchQuerys;
    }

    private List<SearchQuery> getDaySearchQuerys(String indexName, String storeCode) {
        List<SearchQuery> searchQuerys = new ArrayList<>();
        searchQuerys.add(this.getDaySearchQuery(indexName, storeCode, dayStr1));
        searchQuerys.add(this.getDaySearchQuery(indexName, storeCode, dayStr2));
        searchQuerys.add(this.getDaySearchQuery(indexName, storeCode, dayStr3));
        searchQuerys.add(this.getDaySearchQuery(indexName, storeCode, dayStr4));
        searchQuerys.add(this.getDaySearchQuery(indexName, storeCode, dayStr5));
        searchQuerys.add(this.getDaySearchQuery(indexName, storeCode, dayStr6));
        searchQuerys.add(this.getDaySearchQuery(indexName, storeCode, dayStr7));
        searchQuerys.add(this.getDaySearchQuery(indexName, storeCode, dayStr8));
        searchQuerys.add(this.getDaySearchQuery(indexName, storeCode, dayStr9));
        searchQuerys.add(this.getDaySearchQuery(indexName, storeCode, dayStr10));
        searchQuerys.add(this.getDaySearchQuery(indexName, storeCode, dayStr11));
        searchQuerys.add(this.getDaySearchQuery(indexName, storeCode, dayStr12));
        searchQuerys.add(this.getDaySearchQuery(indexName, storeCode, dayStr13));
        return searchQuerys;
    }

    private SearchQuery getWeekSearchQuery(String indexName, String storeCode, String startDateStr) {
        return new NativeSearchQueryBuilder()
                .withQuery(
                        QueryBuilders.boolQuery()
                                .filter(termQuery("planStartDate", startDateStr))
                                .must(matchQuery("storeCode", storeCode))
                ).withIndices(indexName).withPageable(PageRequest.of(0, 10000)).build();
    }

    private SearchQuery getDaySearchQuery(String indexName, String storeCode, String formulateDate) {
        return new NativeSearchQueryBuilder()
                .withQuery(
                        QueryBuilders.boolQuery()
                                .filter(termQuery("formulateDate", formulateDate))
                                .must(matchQuery("storeCode", storeCode))
                ).withIndices(indexName).withPageable(PageRequest.of(0, 10000)).build();
    }

//    /**
//     * 门店实体转换
//     *
//     * @param sourceAsMap
//     * @return {@link SalesPlanStoreEntity}
//     **/
//    private SalesPlanStoreEntity setStoreField(Map<String, Object> sourceAsMap) {
//        SalesPlanStoreEntity salesPlanStoreEntity = new SalesPlanStoreEntity();
//        salesPlanStoreEntity.setSkuCode(sourceAsMap.get("skuCode").toString());
//        salesPlanStoreEntity.setStoreCode(sourceAsMap.get("storeCode").toString());
//        salesPlanStoreEntity.setFormulateDate(sourceAsMap.get("formulateDate").toString());
//        salesPlanStoreEntity.setForecastQty(new BigDecimal(sourceAsMap.get("forecastQty").toString()));
//        salesPlanStoreEntity.setConfirmQty(new BigDecimal(sourceAsMap.get("confirmQty").toString()));
//        return salesPlanStoreEntity;
//    }
//
//    private SalesPlanExecuteEntity setExecuteField(Map<String, Object> sourceAsMap) {
//        SalesPlanExecuteEntity salesPlanExecuteEntity = new SalesPlanExecuteEntity();
//        salesPlanExecuteEntity.setSkuCode(sourceAsMap.get("skuCode").toString());
//        salesPlanExecuteEntity.setStoreCode(sourceAsMap.get("storeCode").toString());
//        salesPlanExecuteEntity.setFormulateDate(sourceAsMap.get("formulateDate").toString());
//        salesPlanExecuteEntity.setForecastSalesAmount(new BigDecimal(sourceAsMap.get("forecastSalesAmount").toString()));
//        return salesPlanExecuteEntity;
//    }
//
//    private SalesPlanDirectlyEntity setDirectlyField(Map<String, Object> sourceAsMap) {
//        SalesPlanDirectlyEntity salesPlanDirectlyEntity = new SalesPlanDirectlyEntity();
//        salesPlanDirectlyEntity.setSkuCode(sourceAsMap.get("skuCode").toString());
//        salesPlanDirectlyEntity.setStoreCode(sourceAsMap.get("storeCode").toString());
//        salesPlanDirectlyEntity.setForecastQty(new BigDecimal(sourceAsMap.get("forecastQty").toString()));
//        salesPlanDirectlyEntity.setPlanStartDate(sourceAsMap.get("planStartDate").toString());
//        salesPlanDirectlyEntity.setPlanEndDate(sourceAsMap.get("planEndDate").toString());
//        return salesPlanDirectlyEntity;
//    }
//
//    private SalesPlanDifferinEntity setDifferinField(Map<String, Object> sourceAsMap) {
//        SalesPlanDifferinEntity salesPlanDifferinEntity = new SalesPlanDifferinEntity();
//        salesPlanDifferinEntity.setSkuCode(sourceAsMap.get("skuCode").toString());
//        salesPlanDifferinEntity.setStoreCode(sourceAsMap.get("storeCode").toString());
//        salesPlanDifferinEntity.setSalesForecastQty(new BigDecimal(sourceAsMap.get("salesForecastQty").toString()));
//        salesPlanDifferinEntity.setPlanStartDate(sourceAsMap.get("planStartDate").toString());
//        salesPlanDifferinEntity.setPlanEndDate(sourceAsMap.get("planEndDate").toString());
//        return salesPlanDifferinEntity;
//    }
//
//    private SalesPlanAccuracyEntity setAccuracyField(Map<String, Object> sourceAsMap) {
//        SalesPlanAccuracyEntity salesPlanAccuracyEntity = new SalesPlanAccuracyEntity();
//        salesPlanAccuracyEntity.setSkuCode(sourceAsMap.get("skuCode").toString());
//        salesPlanAccuracyEntity.setStoreCode(sourceAsMap.get("storeCode").toString());
//        salesPlanAccuracyEntity.setPredictedQty(new BigDecimal(sourceAsMap.get("predictedQty").toString()));
//        salesPlanAccuracyEntity.setPlanStartDate(sourceAsMap.get("planStartDate").toString());
//        salesPlanAccuracyEntity.setPlanEndDate(sourceAsMap.get("planEndDate").toString());
//        return salesPlanAccuracyEntity;
//    }

    /**
     * 循环获取日补货接口数据
     *
     * @param bigDataGeneralQueryBaseDTO
     * @return void
     **/
    private List<BigDataGeneralInfoDTO> getBigDataGeneralInfo(BigDataGeneralQueryBaseDTO bigDataGeneralQueryBaseDTO) {
        List<BigDataGeneralInfoDTO> itemDTOS = cprfCoreFacade.getDayPredictReplenishment(bigDataGeneralQueryBaseDTO);
        List<BigDataGeneralInfoDTO> bigDataGeneralInfoDTOs = new ArrayList<>(itemDTOS);
        while (itemDTOS.size() == CommonConstants.BIG_DATA_PAGE_SIZE) {
            bigDataGeneralQueryBaseDTO.setPageNo(bigDataGeneralQueryBaseDTO.getPageNo() + 1);
            itemDTOS = cprfCoreFacade.getDayPredictReplenishment(bigDataGeneralQueryBaseDTO);
            bigDataGeneralInfoDTOs.addAll(itemDTOS);
        }
        return bigDataGeneralInfoDTOs;
    }

    /**
     * 大数据查询实体
     *
     * @param storeCode
     * @param nowDateStr
     * @return {@link BigDataGeneralQueryBaseDTO}
     **/
    private BigDataGeneralQueryBaseDTO getGeneralQueryBaseDTO(String storeCode, String nowDateStr) {
        BigDataGeneralQueryBaseDTO bigDataGeneralQueryBaseDTO = new BigDataGeneralQueryBaseDTO();
        bigDataGeneralQueryBaseDTO.setStartDate(nowDateStr);
        bigDataGeneralQueryBaseDTO.setEndDate(nowDateStr);
        bigDataGeneralQueryBaseDTO.setStore(storeCode);
        bigDataGeneralQueryBaseDTO.setPageNo(1);
        bigDataGeneralQueryBaseDTO.setPageSize(CommonConstants.BIG_DATA_PAGE_SIZE);
        return bigDataGeneralQueryBaseDTO;
    }

    private void setExecutePredictValue(SalesPlanExecuteEntity salesPlanExecuteEntity, BigDataGeneralInfoDTO bigDataGeneralInfoDTO) {
        //获取对应日期的预测值
        String dateStr = salesPlanExecuteEntity.getFormulateDate();
        if (dayStr1.equals(dateStr)) {
            this.setDirectExecuteValue(salesPlanExecuteEntity, bigDataGeneralInfoDTO.getSalesDayf1());
            return;
        }
        if (dayStr2.equals(dateStr)) {
            this.setDirectExecuteValue(salesPlanExecuteEntity, bigDataGeneralInfoDTO.getSalesDayf2());
            return;
        }
        if (dayStr3.equals(dateStr)) {
            this.setDirectExecuteValue(salesPlanExecuteEntity, bigDataGeneralInfoDTO.getSalesDayf3());
            return;
        }
        if (dayStr4.equals(dateStr)) {
            this.setDirectExecuteValue(salesPlanExecuteEntity, bigDataGeneralInfoDTO.getSalesDayf4());
            return;
        }
        if (dayStr5.equals(dateStr)) {
            this.setDirectExecuteValue(salesPlanExecuteEntity, bigDataGeneralInfoDTO.getSalesDayf5());
            return;
        }
        if (dayStr6.equals(dateStr)) {
            this.setDirectExecuteValue(salesPlanExecuteEntity, bigDataGeneralInfoDTO.getSalesDayf6());
            return;
        }
        if (dayStr7.equals(dateStr)) {
            this.setDirectExecuteValue(salesPlanExecuteEntity, bigDataGeneralInfoDTO.getSalesDayf7());
            return;
        }
        if (dayStr8.equals(dateStr)) {
            this.setDirectExecuteValue(salesPlanExecuteEntity, bigDataGeneralInfoDTO.getSalesDayf8());
            return;
        }
        if (dayStr9.equals(dateStr)) {
            this.setDirectExecuteValue(salesPlanExecuteEntity, bigDataGeneralInfoDTO.getSalesDayf9());
            return;
        }
        if (dayStr10.equals(dateStr)) {
            this.setDirectExecuteValue(salesPlanExecuteEntity, bigDataGeneralInfoDTO.getSalesDayf10());
            return;
        }
        if (dayStr11.equals(dateStr)) {
            this.setDirectExecuteValue(salesPlanExecuteEntity, bigDataGeneralInfoDTO.getSalesDayf11());
            return;
        }
        if (dayStr12.equals(dateStr)) {
            this.setDirectExecuteValue(salesPlanExecuteEntity, bigDataGeneralInfoDTO.getSalesDayf12());
            return;
        }
        if (dayStr13.equals(dateStr)) {
            this.setDirectExecuteValue(salesPlanExecuteEntity, bigDataGeneralInfoDTO.getSalesDayf13());
        }
    }

    private void setDirectlyPredictValue(SalesPlanDirectlyEntity salesPlanDirectlyEntity, BigDataGeneralInfoDTO bigDataGeneralInfoDTO) {
        //获取对应日期的预测值
        String startDateStr = salesPlanDirectlyEntity.getPlanStartDate();
        if (startDateStr1.equals(startDateStr)) {
            this.setDirectValue(salesPlanDirectlyEntity, bigDataGeneralInfoDTO.getSalesWeekf1());
            return;
        }
        if (startDateStr2.equals(startDateStr)) {
            this.setDirectValue(salesPlanDirectlyEntity, bigDataGeneralInfoDTO.getSalesDayf2());
            return;
        }
        if (startDateStr3.equals(startDateStr)) {
            this.setDirectValue(salesPlanDirectlyEntity, bigDataGeneralInfoDTO.getSalesDayf3());
            return;
        }
        if (startDateStr4.equals(startDateStr)) {
            this.setDirectValue(salesPlanDirectlyEntity, bigDataGeneralInfoDTO.getSalesDayf4());
            return;
        }
        if (startDateStr5.equals(startDateStr)) {
            this.setDirectValue(salesPlanDirectlyEntity, bigDataGeneralInfoDTO.getSalesDayf5());
            return;
        }
        if (startDateStr6.equals(startDateStr)) {
            this.setDirectValue(salesPlanDirectlyEntity, bigDataGeneralInfoDTO.getSalesDayf6());
            return;
        }
        if (startDateStr7.equals(startDateStr)) {
            this.setDirectValue(salesPlanDirectlyEntity, bigDataGeneralInfoDTO.getSalesDayf7());
            return;
        }
        if (startDateStr8.equals(startDateStr)) {
            this.setDirectValue(salesPlanDirectlyEntity, bigDataGeneralInfoDTO.getSalesDayf8());
            return;
        }
        if (startDateStr9.equals(startDateStr)) {
            this.setDirectValue(salesPlanDirectlyEntity, bigDataGeneralInfoDTO.getSalesDayf9());
            return;
        }
        if (startDateStr10.equals(startDateStr)) {
            this.setDirectValue(salesPlanDirectlyEntity, bigDataGeneralInfoDTO.getSalesDayf10());
            return;
        }
        if (startDateStr11.equals(startDateStr)) {
            this.setDirectValue(salesPlanDirectlyEntity, bigDataGeneralInfoDTO.getSalesDayf11());
            return;
        }
        if (startDateStr12.equals(startDateStr)) {
            this.setDirectValue(salesPlanDirectlyEntity, bigDataGeneralInfoDTO.getSalesDayf12());
        }
    }

    private void setDifferinPredictValue(SalesPlanDifferinEntity salesPlanDifferinEntity, BigDataGeneralInfoDTO bigDataGeneralInfoDTO) {
        //获取对应日期的预测值
        String startDateStr = salesPlanDifferinEntity.getPlanStartDate();
        if (startDateStr1.equals(startDateStr)) {
            this.setDifferinValue(salesPlanDifferinEntity, bigDataGeneralInfoDTO.getSalesWeekf1());
            return;
        }
        if (startDateStr2.equals(startDateStr)) {
            this.setDifferinValue(salesPlanDifferinEntity, bigDataGeneralInfoDTO.getSalesDayf2());
            return;
        }
        if (startDateStr3.equals(startDateStr)) {
            this.setDifferinValue(salesPlanDifferinEntity, bigDataGeneralInfoDTO.getSalesDayf3());
            return;
        }
        if (startDateStr4.equals(startDateStr)) {
            this.setDifferinValue(salesPlanDifferinEntity, bigDataGeneralInfoDTO.getSalesDayf4());
            return;
        }
        if (startDateStr5.equals(startDateStr)) {
            this.setDifferinValue(salesPlanDifferinEntity, bigDataGeneralInfoDTO.getSalesDayf5());
            return;
        }
        if (startDateStr6.equals(startDateStr)) {
            this.setDifferinValue(salesPlanDifferinEntity, bigDataGeneralInfoDTO.getSalesDayf6());
            return;
        }
        if (startDateStr7.equals(startDateStr)) {
            this.setDifferinValue(salesPlanDifferinEntity, bigDataGeneralInfoDTO.getSalesDayf7());
            return;
        }
        if (startDateStr8.equals(startDateStr)) {
            this.setDifferinValue(salesPlanDifferinEntity, bigDataGeneralInfoDTO.getSalesDayf8());
            return;
        }
        if (startDateStr9.equals(startDateStr)) {
            this.setDifferinValue(salesPlanDifferinEntity, bigDataGeneralInfoDTO.getSalesDayf9());
            return;
        }
        if (startDateStr10.equals(startDateStr)) {
            this.setDifferinValue(salesPlanDifferinEntity, bigDataGeneralInfoDTO.getSalesDayf10());
            return;
        }
        if (startDateStr11.equals(startDateStr)) {
            this.setDifferinValue(salesPlanDifferinEntity, bigDataGeneralInfoDTO.getSalesDayf11());
            return;
        }
        if (startDateStr12.equals(startDateStr)) {
            this.setDifferinValue(salesPlanDifferinEntity, bigDataGeneralInfoDTO.getSalesDayf12());
        }
    }

    private void setAccuracyPredictValue(SalesPlanAccuracyEntity salesPlanAccuracyEntity, BigDataGeneralInfoDTO bigDataGeneralInfoDTO) {
        //获取对应日期的预测值
        String startDateStr = salesPlanAccuracyEntity.getPlanStartDate();
        if (startDateStr1.equals(startDateStr)) {
            this.setAccuracyValue(salesPlanAccuracyEntity, bigDataGeneralInfoDTO.getSalesWeekf1());
            return;
        }
        if (startDateStr2.equals(startDateStr)) {
            this.setAccuracyValue(salesPlanAccuracyEntity, bigDataGeneralInfoDTO.getSalesDayf2());
            return;
        }
        if (startDateStr3.equals(startDateStr)) {
            this.setAccuracyValue(salesPlanAccuracyEntity, bigDataGeneralInfoDTO.getSalesDayf3());
            return;
        }
        if (startDateStr4.equals(startDateStr)) {
            this.setAccuracyValue(salesPlanAccuracyEntity, bigDataGeneralInfoDTO.getSalesDayf4());
            return;
        }
        if (startDateStr5.equals(startDateStr)) {
            this.setAccuracyValue(salesPlanAccuracyEntity, bigDataGeneralInfoDTO.getSalesDayf5());
            return;
        }
        if (startDateStr6.equals(startDateStr)) {
            this.setAccuracyValue(salesPlanAccuracyEntity, bigDataGeneralInfoDTO.getSalesDayf6());
            return;
        }
        if (startDateStr7.equals(startDateStr)) {
            this.setAccuracyValue(salesPlanAccuracyEntity, bigDataGeneralInfoDTO.getSalesDayf7());
            return;
        }
        if (startDateStr8.equals(startDateStr)) {
            this.setAccuracyValue(salesPlanAccuracyEntity, bigDataGeneralInfoDTO.getSalesDayf8());
            return;
        }
        if (startDateStr9.equals(startDateStr)) {
            this.setAccuracyValue(salesPlanAccuracyEntity, bigDataGeneralInfoDTO.getSalesDayf9());
            return;
        }
        if (startDateStr10.equals(startDateStr)) {
            this.setAccuracyValue(salesPlanAccuracyEntity, bigDataGeneralInfoDTO.getSalesDayf10());
            return;
        }
        if (startDateStr11.equals(startDateStr)) {
            this.setAccuracyValue(salesPlanAccuracyEntity, bigDataGeneralInfoDTO.getSalesDayf11());
            return;
        }
        if (startDateStr12.equals(startDateStr)) {
            this.setAccuracyValue(salesPlanAccuracyEntity, bigDataGeneralInfoDTO.getSalesDayf12());
        }
    }

    /**
     * 插入操作日志
     *
     * @param
     * @return void
     **/
    private void writeOperateLog(Long time) {
        //插入该批次数据日志
        List<OperationLogRecordDO> operationLogRecordDOs = new ArrayList<>(4);
        operationLogRecordDOs.add(OperationLogRecordUtil.getBigDataOperationLog(opSign, OperationDataEnum.DIRECTLY_EXECUTE.getTableType(), time + "ms", OpContentEnum.BIG_DATA_OPERATION_DIRECT_LOG.getIndex().toString(), OpContentEnum.BIG_DATA_OPERATION_DIRECT_LOG.getDesc()));
        if (validWeekJob) {
            operationLogRecordDOs.add(OperationLogRecordUtil.getBigDataOperationLog(opSign, OperationDataEnum.DIRECTLY_ACCURACY.getTableType(), time + "ms", OpContentEnum.BIG_DATA_OPERATION_DIRECT_LOG.getIndex().toString(), OpContentEnum.BIG_DATA_OPERATION_DIRECT_LOG.getDesc()));
            operationLogRecordDOs.add(OperationLogRecordUtil.getBigDataOperationLog(opSign, OperationDataEnum.DIRECTLY_DIFFERIN.getTableType(), time + "ms", OpContentEnum.BIG_DATA_OPERATION_DIRECT_LOG.getIndex().toString(), OpContentEnum.BIG_DATA_OPERATION_DIRECT_LOG.getDesc()));
            operationLogRecordDOs.add(OperationLogRecordUtil.getBigDataOperationLog(opSign, OperationDataEnum.PLAN_DIRECTLY.getTableType(), time + "ms", OpContentEnum.BIG_DATA_OPERATION_DIRECT_LOG.getIndex().toString(), OpContentEnum.BIG_DATA_OPERATION_DIRECT_LOG.getDesc()));
        }
        operationLogRecordRepository.batchAddOperationLogRecord(operationLogRecordDOs);
    }

    /**
     * 判断是否需要触发周数据任务（默认为每周一才能触发）
     *
     * @param
     * @return {@link boolean}
     **/
    private boolean validWeekJob(Date date) {
        return DateUtil.dayOfWeek(date) == 2;
    }

    /**
     * 索引映射
     *
     * @param
     * @return {@link String}
     **/
    private String getDirectlyMapping() {
        return "{\n" +
                "      \"properties\": {\n" +
                "        \"id\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "        \"channelCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"channelName\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "        \"priCategoryCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "        \"secCategoryCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t \"terCategoryCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"skuCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t \"provinceCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"cityCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"countyCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"storeCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"forecastQty\":{\n" +
                "          \"type\": \"double\"\n" +
                "        },\n" +
                "\t\t\"lastForecastQty\":{\n" +
                "          \"type\": \"double\"\n" +
                "        },\n" +
                "\t\t\"confirmTarget\":{\n" +
                "          \"type\": \"double\"\n" +
                "        },\n" +
                "\t\t\"planStartDate\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"planEndDate\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"opSign\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"createTime\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"updateTime\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"creator\":{\n" +
                "          \"type\": \"double\"\n" +
                "        },\n" +
                "\t\t\"creatorName\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"modifier\":{\n" +
                "          \"type\": \"double\"\n" +
                "        },\n" +
                "\t\t\"modifierName\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"isAvailable\":{\n" +
                "          \"type\": \"integer\"\n" +
                "        },\n" +
                "\t\t\"isDeleted\":{\n" +
                "          \"type\": \"integer\"\n" +
                "        },\n" +
                "\t\t\"versionNo\":{\n" +
                "          \"type\": \"integer\"\n" +
                "        },\n" +
                "\t\t\"merchantId\":{\n" +
                "          \"type\": \"double\"\n" +
                "        },\n" +
                "\t\t\"appId\":{\n" +
                "          \"type\": \"double\"\n" +
                "        },\n" +
                "\t\t\"userDef1\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef2\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef3\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef4\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef5\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef6\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef7\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef8\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        }\n" +
                "      }\n" +
                "    }\n" +
                "\t\n";
    }

    private String getDifferinMapping() {
        return "{\n" +
                "      \"properties\": {\n" +
                "        \"id\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "        \"channelCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"channelName\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "        \"priCategoryCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "        \"secCategoryCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t \"terCategoryCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"skuCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t \"provinceCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"cityCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"countyCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"storeCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"salesForecastQty\":{\n" +
                "          \"type\": \"double\"\n" +
                "        },\n" +
                "\t\t\"planStartDate\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"planEndDate\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"opSign\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"createTime\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"updateTime\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"creator\":{\n" +
                "          \"type\": \"double\"\n" +
                "        },\n" +
                "\t\t\"creatorName\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"modifier\":{\n" +
                "          \"type\": \"double\"\n" +
                "        },\n" +
                "\t\t\"modifierName\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"isAvailable\":{\n" +
                "          \"type\": \"integer\"\n" +
                "        },\n" +
                "\t\t\"isDeleted\":{\n" +
                "          \"type\": \"integer\"\n" +
                "        },\n" +
                "\t\t\"versionNo\":{\n" +
                "          \"type\": \"integer\"\n" +
                "        },\n" +
                "\t\t\"merchantId\":{\n" +
                "          \"type\": \"double\"\n" +
                "        },\n" +
                "\t\t\"appId\":{\n" +
                "          \"type\": \"double\"\n" +
                "        },\n" +
                "\t\t\"userDef1\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef2\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef3\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef4\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef5\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef6\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef7\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef8\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        }\n" +
                "      }\n" +
                "    }\n" +
                "\t\n";
    }

    private String getAccuracyMapping() {
        return "{\n" +
                "      \"properties\": {\n" +
                "        \"id\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "        \"channelCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"channelName\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "        \"priCategoryCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "        \"secCategoryCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t \"terCategoryCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"skuCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t \"provinceCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"cityCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"countyCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"storeCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"predictedQty\":{\n" +
                "          \"type\": \"double\"\n" +
                "        },\n" +
                "\t\t\"planStartDate\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"planEndDate\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"opSign\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"createTime\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"updateTime\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"creator\":{\n" +
                "          \"type\": \"double\"\n" +
                "        },\n" +
                "\t\t\"creatorName\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"modifier\":{\n" +
                "          \"type\": \"double\"\n" +
                "        },\n" +
                "\t\t\"modifierName\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"isAvailable\":{\n" +
                "          \"type\": \"integer\"\n" +
                "        },\n" +
                "\t\t\"isDeleted\":{\n" +
                "          \"type\": \"integer\"\n" +
                "        },\n" +
                "\t\t\"versionNo\":{\n" +
                "          \"type\": \"integer\"\n" +
                "        },\n" +
                "\t\t\"merchantId\":{\n" +
                "          \"type\": \"double\"\n" +
                "        },\n" +
                "\t\t\"appId\":{\n" +
                "          \"type\": \"double\"\n" +
                "        },\n" +
                "\t\t\"userDef1\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef2\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef3\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef4\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef5\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef6\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef7\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef8\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        }\n" +
                "      }\n" +
                "    }\n" +
                "\t\n";
    }

    private String getExecuteMapping() {
        return "{\n" +
                "      \"properties\": {\n" +
                "        \"id\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "        \"channelCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"channelName\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "        \"priCategoryCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "        \"secCategoryCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t \"terCategoryCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"skuCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t \"provinceCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"cityCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"countyCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"storeCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"forecastSalesAmount\":{\n" +
                "          \"type\": \"double\"\n" +
                "        },\n" +
                "\t\t\"formulateDate\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"opSign\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"createTime\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"updateTime\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"creator\":{\n" +
                "          \"type\": \"double\"\n" +
                "        },\n" +
                "\t\t\"creatorName\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"modifier\":{\n" +
                "          \"type\": \"double\"\n" +
                "        },\n" +
                "\t\t\"modifierName\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"isAvailable\":{\n" +
                "          \"type\": \"integer\"\n" +
                "        },\n" +
                "\t\t\"isDeleted\":{\n" +
                "          \"type\": \"integer\"\n" +
                "        },\n" +
                "\t\t\"versionNo\":{\n" +
                "          \"type\": \"integer\"\n" +
                "        },\n" +
                "\t\t\"merchantId\":{\n" +
                "          \"type\": \"double\"\n" +
                "        },\n" +
                "\t\t\"appId\":{\n" +
                "          \"type\": \"double\"\n" +
                "        },\n" +
                "\t\t\"userDef1\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef2\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef3\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef4\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef5\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef6\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef7\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef8\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        }\n" +
                "      }\n" +
                "    }\n" +
                "\t\n";
    }

    private String getStoreMapping() {
        return "{\n" +
                "      \"properties\": {\n" +
                "        \"id\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "        \"channelCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"channelName\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "        \"priCategoryCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "        \"secCategoryCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t \"terCategoryCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"skuCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t \"provinceCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"cityCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"countyCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"storeCode\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"forecastQty\":{\n" +
                "          \"type\": \"double\"\n" +
                "        },\n" +
                "\t\t\"lastForecastQty\":{\n" +
                "          \"type\": \"double\"\n" +
                "        },\n" +
                "\t\t\"confirmQty\":{\n" +
                "          \"type\": \"double\"\n" +
                "        },\n" +
                "\t\t\"lastConfirmQty\":{\n" +
                "          \"type\": \"double\"\n" +
                "        },\n" +
                "\t\t\"status\":{\n" +
                "          \"type\": \"integer\"\n" +
                "        },\n" +
                "\t\t\"updateStatus\":{\n" +
                "          \"type\": \"integer\"      \n" +
                "        },\n" +
                "\t\t\"submitTime\":{\n" +
                "          \"type\": \"keyword\"      \n" +
                "        },\n" +
                "\t\t\"formulateDate\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"opSign\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"createTime\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"updateTime\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"creator\":{\n" +
                "          \"type\": \"double\"\n" +
                "        },\n" +
                "\t\t\"creatorName\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"modifier\":{\n" +
                "          \"type\": \"double\"\n" +
                "        },\n" +
                "\t\t\"modifierName\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"isAvailable\":{\n" +
                "          \"type\": \"integer\"\n" +
                "        },\n" +
                "\t\t\"isDeleted\":{\n" +
                "          \"type\": \"integer\"\n" +
                "        },\n" +
                "\t\t\"versionNo\":{\n" +
                "          \"type\": \"integer\"\n" +
                "        },\n" +
                "\t\t\"merchantId\":{\n" +
                "          \"type\": \"double\"\n" +
                "        },\n" +
                "\t\t\"appId\":{\n" +
                "          \"type\": \"double\"\n" +
                "        },\n" +
                "\t\t\"userDef1\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef2\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef3\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef4\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef5\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef6\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef7\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "\t\t\"userDef8\":{\n" +
                "          \"type\": \"keyword\"\n" +
                "        }\n" +
                "      }\n" +
                "    }\n" +
                "\t\n";
    }
}
